const { Model, DataTypes } = require('sequelize')
const { createFields } = require('../helper')
module.exports = (sequelize) => {
  class System extends Model {
    static associate({ Menu }) {
      System.hasMany(Menu, {
        constraints: false,
        as: 'menuList',
      })
    }
  }
  System.init(
    createFields({
      name: { type: DataTypes.STRING, comment: '系统名称' },
      code: { type: DataTypes.STRING, comment: '系统编码' },
      description: {
        type: DataTypes.STRING,
        comment: '系统描述',
        allowNull: true,
      },
      url: { type: DataTypes.STRING, comment: '系统连接', allowNull: true },
      icon: {
        type: DataTypes.STRING(255),
        comment: '系统图标',
        allowNull: true,
      },
    }),
    {
      sequelize,
      tableName: 'sys_system',
      timestamps: true,
      modelName: 'System',
    }
  )
  return System
}
